#!/bin/bash

export TODAY=$(date +%Y-%m-%d)

# Core
export ZMICRO_NAME=zmicro
export ZMICRO_HOME=/usr/local/lib/zmicro
export ZMICRO_BIN=$ZMICRO_HOME/bin/zmicro
export ZMICRO_LOCAL_BIN=/usr/local/bin/zmicro

# Repo
export ZMICRO_GIT=https://github.com/zcorky/zmicro

# RC
export ZMICRO_RC=$HOME/.zmicrorc

# Mod
export ZMICRO_MOD=$ZMICRO_HOME/mod

# Log
export ZMICRO_LOG_PATH=/var/log/${ZMICRO_NAME} #/tmp/zmicro

# Lock
export ZMICRO_LOCK_UPDATE_PATH=$ZMICRO_LOG_PATH/update.lock

export ZMICRO_LOG_COMMON_PATH=$ZMICRO_LOG_PATH/common.$TODAY.log
export ZMICRO_LOG_DEBUG_PATH=$ZMICRO_LOG_PATH/debug.log
export ZMICRO_LOG_ERROR_PATH=$ZMICRO_LOG_PATH/error.log

export ZMICRO_LOG_UPDATE_PATH=$ZMICRO_LOG_PATH/update.log
export ZMICRO_LOG_VERSION_PATH=$ZMICRO_LOG_PATH/version.log
export ZMICRO_LOG_NOTIFY_PATH=$ZMICRO_LOG_PATH/notify.log

# Data
export ZMICRO_APP_DATA_PATH=/data
# Logs
export ZMICRO_APP_LOGS_PATH=/logs
# Configs
export ZMICRO_APP_CONFIGS_PATH=/configs

# @TODO MAC
[[ "$(uname -s)" = "Darwin" ]] && export ZMICRO_APP_DATA_PATH=/opt/data
[[ "$(uname -s)" = "Darwin" ]] && export ZMICRO_APP_LOGS_PATH=/opt/logs
[[ "$(uname -s)" = "Darwin" ]] && export ZMICRO_APP_CONFIGS_PATH=/opt/configs

# Plugin
export ZMICRO_PLUGINS_PATH=$ZMICRO_HOME/plugins

export ZMICRO_PLUGIN_GITHUB="https://github.com/zmicro-design"
export ZMICRO_PLUGIN_REPO_PREFIX="$ZMICRO_PLUGIN_GITHUB/plugin-"

export ZMICRO_PLUGINS_DATA_PATH=$ZMICRO_APP_DATA_PATH/plugins
export ZMICRO_PLUGINS_LOGS_PATH=$ZMICRO_APP_LOGS_PATH/plugins
export ZMICRO_PLUGINS_CONFIGS_PATH=$ZMICRO_APP_CONFIGS_PATH/plugins

# PATHS
export ZMICRO_BIN_PATH=$ZMICRO_HOME/bin #$(realpath $(dirname "$0"))
export ZMICRO_SUB_BIN_PATH=$ZMICRO_BIN_PATH/sub
export ZMICRO_CORE_PATH=$ZMICRO_HOME/core
export ZMICRO_CONFIGS_PATH=$ZMICRO_HOME/config
export ZMICRO_COMMANDS_PATH=$ZMICRO_HOME/commands
export ZMICRO_SERVICES_PATH=$ZMICRO_HOME/services

# export DATA_INFLUX_PATH=$ZMICRO_APP_DATA_PATH/influx
# export DATA_POSTGRES_PATH=$ZMICRO_APP_DATA_PATH/postgres

# DEFAULT GIT
export DEFAULT_GIT_USERNAME=$USER
export DEFAULT_GIT_PASSWORD=
export DEFAULT_GIT_EMAIL=$USER@local
